<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>add</title>
</head>
<script src="util.js"></script>
<script src="vue.js"></script>
<script src="axios.js"></script>
<body>
{{page}}
    <div id="app">
        <input type="hidden" v-model="emp.eid">
        姓名：
        <input type="text" v-model="emp.ename"><br>
        性别：
        <input type="radio" v-model="emp.sex" value="1">男
        <input type="radio" v-model="emp.sex" value="2">女<br>
        地址：
        <input type="text" v-model="emp.address"><br>
        生日：
        <input type="date" v-model="emp.birthday"><br>

        <input type="button" value="修改" @click="updateEmps()">
    </div>
<script>
    new Vue({
        el:"#app",
        data:{
            emp:{
                eid:"",
                ename:"",
                sex:"",
                address:"",
                birthday:""
            }
        },
        created(){
            this.findYbEid()
        },
        methods:{
            updateEmps(){
                var a={"eid":this.emp.eid,"ename":this.emp.ename,"sex":this.emp.sex,"address":this.emp.address,"birthday":this.emp.birthday}
                axios.post("/emp/update",a).then(
                    location.href="emp.html"
                )
            },
            findYbEid(){
                axios.get("/emp/findByEid?eid="+getQueryString("eid")).then(
                    res=>{
                        this.emp=res.data
                    }
                )
            }
        }
    })
</script>
</body>
</html>